<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JIT编译器：Java性能优化的魔法师</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
        }
        
        .code-container {
            background: #1e1e1e;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 20px 40px rgba(0,0,0,0.15);
            transition: transform 0.3s ease;
        }
        
        .code-container:hover {
            transform: translateY(-5px);
        }
        
        .code-header {
            background: #2d2d2d;
            padding: 10px 20px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .code-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
        }
        
        pre {
            margin: 0;
            padding: 20px;
            overflow-x: auto;
        }
        
        code {
            color: #d4d4d4;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
        }
        
        .keyword { color: #569cd6; }
        .string { color: #ce9178; }
        .number { color: #b5cea8; }
        .comment { color: #6a9955; }
        .method { color: #dcdcaa; }
        
        .feature-card {
            background: white;
            border-radius: 16px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            transition: all 0.3s ease;
            border: 1px solid transparent;
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 40px rgba(0,0,0,0.15);
            border-color: #667eea;
        }
        
        .section-title {
            position: relative;
            display: inline-block;
            margin-bottom: 2rem;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea, #764ba2);
            border-radius: 2px;
        }
        
        .mermaid {
            background: white;
            padding: 30px;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .highlight-text {
            background: linear-gradient(120deg, #f093fb 0%, #f5576c 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 700;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white">
        <div class="container mx-auto px-6 py-20">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight">
                    JIT编译器
                </h1>
                <p class="text-2xl md:text-3xl mb-8 opacity-90">
                    Java性能优化的<span class="highlight-text">魔法师</span>
                </p>
                <div class="flex justify-center items-center gap-8 text-lg">
                    <div class="flex items-center gap-2">
                        <i class="fas fa-rocket"></i>
                        <span>即时编译</span>
                    </div>
                    <div class="flex items-center gap-2">
                        <i class="fas fa-bolt"></i>
                        <span>性能提升</span>
                    </div>
                    <div class="flex items-center gap-2">
                        <i class="fas fa-cogs"></i>
                        <span>智能优化</span>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-16 max-w-6xl">
        <!-- Introduction -->
        <div class="bg-white rounded-2xl shadow-xl p-10 mb-12">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">什么是JIT编译器？</h2>
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">J</span>IT（Just-In-Time）编译器是Java虚拟机（JVM）中的一个重要组件，它负责将Java字节码即时编译成本地机器码，以提高程序的执行效率。JIT编译器在运行时动态地将字节码翻译成机器码，这种编译方式与传统的静态编译和解释执行相比，可以兼顾编译速度和执行效率，是Java程序运行的关键技术之一。
            </p>
        </div>

        <!-- Working Process Visualization -->
        <div class="mb-16">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">JIT编译器工作流程</h2>
            <div class="mermaid">
                graph LR
                    A[Java源代码] -->|javac编译| B[字节码.class]
                    B -->|类加载器| C[JVM内存]
                    C -->|解释执行| D[解释器]
                    C -->|热点检测| E[JIT编译器]
                    E -->|编译优化| F[本地机器码]
                    F -->|直接执行| G[CPU]
                    D -->|执行| G
                    
                    style A fill:#f9f,stroke:#333,stroke-width:2px
                    style E fill:#bbf,stroke:#333,stroke-width:2px
                    style F fill:#bfb,stroke:#333,stroke-width:2px
            </div>
        </div>

        <!-- Code Example Section -->
        <div class="mb-16">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">实例演示</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Original Code -->
                <div>
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">
                        <i class="fas fa-code text-purple-600 mr-2"></i>原始Java代码
                    </h3>
                    <div class="code-container">
                        <div class="code-header">
                            <div class="code-dot bg-red-500"></div>
                            <div class="code-dot bg-yellow-500"></div>
                            <div class="code-dot bg-green-500"></div>
                            <span class="text-gray-400 ml-4 text-sm">Demo.java</span>
                        </div>
                        <pre><code><span class="keyword">public class</span> <span class="method">Demo</span> {
    <span class="keyword">public static void</span> <span class="method">main</span>(<span class="keyword">String</span>[] args) {
        <span class="keyword">int</span> sum = <span class="number">0</span>;
        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>; i <= <span class="number">1000000</span>; i++) {
            sum += i;
        }
        System.out.<span class="method">println</span>(<span class="string">"Sum: "</span> + sum);
    }
}</code></pre>
                    </div>
                </div>

                <!-- Optimized Code -->
                <div>
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">
                        <i class="fas fa-magic text-purple-600 mr-2"></i>JIT优化后的等效代码
                    </h3>
                    <div class="code-container">
                        <div class="code-header">
                            <div class="code-dot bg-red-500"></div>
                            <div class="code-dot bg-yellow-500"></div>
                            <div class="code-dot bg-green-500"></div>
                            <span class="text-gray-400 ml-4 text-sm">Optimized.java</span>
                        </div>
                        <pre><code><span class="keyword">public class</span> <span class="method">Example</span> {
    <span class="keyword">public static void</span> <span class="method">main</span>(<span class="keyword">String</span>[] args) {
        <span class="keyword">int</span> sum = <span class="number">0</span>;
        <span class="comment">// 使用等差数列求和公式</span>
        sum = (<span class="number">999999</span> * (<span class="number">999999</span> + <span class="number">1</span>)) / <span class="number">2</span>;
        System.out.<span class="method">println</span>(<span class="string">"Sum: "</span> + sum);
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </div>

        <!-- Features Grid -->
        <div class="mb-16">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">JIT编译器的核心特性</h2>
            <div class="grid md:grid-cols-3 gap-6">
                <div class="feature-card">
                    <div class="text-4xl text-purple-600 mb-4">
                        <i class="fas fa-tachometer-alt"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">热点检测</h3>
                    <p class="text-gray-600">识别频繁执行的代码段（热点代码），优先进行编译优化，提高整体性能。</p>
                </div>
                
                <div class="feature-card">
                    <div class="text-4xl text-purple-600 mb-4">
                        <i class="fas fa-layer-group"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">分层编译</h3>
                    <p class="text-gray-600">采用多级编译策略，平衡编译时间和代码质量，实现渐进式优化。</p>
                </div>
                
                <div class="feature-card">
                    <div class="text-4xl text-purple-600 mb-4">
                        <i class="fas fa-brain"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">智能优化</h3>
                    <p class="text-gray-600">包括内联、循环展开、死代码消除等多种优化技术，大幅提升执行效率。</p>
                </div>
            </div>
        </div>

        <!-- Performance Comparison -->
        <div class="bg-gradient-to-r from-purple-50 to-pink-50 rounded-2xl p-10 mb-16">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">性能对比</h2>
            <div class="grid md:grid-cols-2 gap-8 items-center">
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-gray-700">优化效果显著</h3>
                    <p class="text-lg text-gray-600 mb-6">
                        通过JIT编译器的优化，Java程序可以在运行时达到接近原生代码的性能水平。在上述示例中，原本需要执行100万次的循环操作，被优化为一个简单的数学公式计算，性能提升可达数千倍。
                    </p>
                    <div class="flex gap-4">
                        <div class="text-center">
                            <div class="text-3xl font-bold text-purple-600">1000x</div>
                            <div class="text-sm text-gray-600">循环优化提升</div>
                        </div>
                        <div class="text-center">
                            <div class="text-3xl font-bold text-purple-600">90%</div>
                            <div class="text-sm text-gray-600">接近原生性能</div>
                        </div>
                    </div>
                </div>
                <div class="text-center">
                    <i class="fas fa-chart-line text-9xl text-purple-400 opacity-50"></i>
                </div>
            </div>
        </div>

        <!-- Summary -->
        <div class="text-center py-12">
            <h2 class="text-3xl font-bold text-gray-800 mb-6">总结</h2>
            <p